package com.subang.function.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.subang.common.annotation.Log;
import com.subang.common.core.controller.BaseController;
import com.subang.common.core.domain.AjaxResult;
import com.subang.common.enums.BusinessType;
import com.subang.function.domain.SbIdiomStudy;
import com.subang.function.service.ISbIdiomStudyService;
import com.subang.common.utils.poi.ExcelUtil;
import com.subang.common.core.page.TableDataInfo;

/**
 * 成语学习Controller
 * 
 * @author subei
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/function/idiom")
public class SbIdiomStudyController extends BaseController
{
    @Autowired
    private ISbIdiomStudyService sbIdiomStudyService;

    /**
     * 查询成语学习列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SbIdiomStudy sbIdiomStudy)
    {
        startPage();
        List<SbIdiomStudy> list = sbIdiomStudyService.selectSbIdiomStudyList(sbIdiomStudy);
        return getDataTable(list);
    }

    /**
     * 导出成语学习列表
     */
    @PreAuthorize("@ss.hasPermi('function:study:export')")
    @Log(title = "成语学习", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SbIdiomStudy sbIdiomStudy)
    {
        List<SbIdiomStudy> list = sbIdiomStudyService.selectSbIdiomStudyList(sbIdiomStudy);
        ExcelUtil<SbIdiomStudy> util = new ExcelUtil<SbIdiomStudy>(SbIdiomStudy.class);
        util.exportExcel(response, list, "成语学习数据");
    }

    /**
     * 获取成语学习详细信息
     */
    @PreAuthorize("@ss.hasPermi('function:study:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sbIdiomStudyService.selectSbIdiomStudyById(id));
    }

    /**
     * 新增成语学习
     */
    @PreAuthorize("@ss.hasPermi('function:study:add')")
    @Log(title = "成语学习", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SbIdiomStudy sbIdiomStudy)
    {
        return toAjax(sbIdiomStudyService.insertSbIdiomStudy(sbIdiomStudy));
    }

    /**
     * 修改成语学习
     */
    @PreAuthorize("@ss.hasPermi('function:study:edit')")
    @Log(title = "成语学习", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SbIdiomStudy sbIdiomStudy)
    {
        return toAjax(sbIdiomStudyService.updateSbIdiomStudy(sbIdiomStudy));
    }

    /**
     * 删除成语学习
     */
    @PreAuthorize("@ss.hasPermi('function:study:remove')")
    @Log(title = "成语学习", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sbIdiomStudyService.deleteSbIdiomStudyByIds(ids));
    }
}
